package com.example.thread.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

/**
 * @Description :
 * @Author : Bruce Lee
 * @CreateTime : 2024/3/1
 */

@Service
@Slf4j
public class AsyncService {
    @Async("AsyncExecutor-test")
    @Scheduled(cron = "0/1 * * * * ?")
    public Future<String> sendMsg() throws InterruptedException {
        log.info("[AsyncService][sendMsg]>>>> 发消息....");
        TimeUnit.SECONDS.sleep(60);
        return new AsyncResult<>("发送成功");
    }
}
